package com.xiaoma.myaudience.biz.task;

import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import android.content.Context;

import com.xiaoma.myaudience.biz.model.ActivityInfoModel;
import com.xiaoma.myaudience.biz.util.Constant;
import com.xiaoma.myaudience.util.HttpUtils;
import com.xiaoma.myaudience.util.Logger;
import com.xiaoma.myaudience.util.model.ModelUtils;
import com.xiaoma.myaudience.util.task.BaseDataAsyncTask;

/**
 * 异步加载活动信息.
 * 
 */
public class ActivitysTask extends BaseDataAsyncTask<Void, Void, List<Map<String, Object>>>{
    private final static String TAG = "ActivitysTask";
    
    public ActivitysTask(Context context, int taskType, DataAsyncCallback callback) {
        super(context, taskType, callback);
    }


    @Override
    protected List<Map<String, Object>> doInBackground(Void... params) {  
    	List<Map<String, Object>> result = null;
        try {            
        	JSONObject jsonObject = HttpUtils.getHttpJSONObjectResult(getHttpClient(), 
        			Constant.URL_ACTIVITY, null, HttpUtils.GET);
        	if (jsonObject != null) {
        			Map<String, Object> objMap = ModelUtils.json2Map(jsonObject);
        			if (objMap != null) {
        				result = ModelUtils.getListMapValue(objMap, ActivityInfoModel.PARAM_DATA);
					}
				}
        } catch (Exception e) {
            Logger.e(TAG, "doInBackground error!!!", e);
        } finally {
            closeHttpClient();
        }
        
        return result;
    }
}
